package com.plian.system.service.cqzc.info.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.http.ResponseEntity;
import com.plian.system.entity.cqzc.info.InfoRegister;
import com.plian.system.mapper.cqzc.info.InfoRegisterMapper;
import com.plian.system.service.cqzc.info.IInfoRegisterService;
import com.plian.system.vo.cqzc.info.InfoRegisterVO;
import com.plian.system.wrapper.cqzc.info.InfoRegisterWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



/**
 * 企业信息登记表 服务实现类
 *
 * @author ziqiang
 * @since 2025-08-29
 */
@Service
@RequiredArgsConstructor
public class InfoRegisterServiceImpl extends ServiceImpl<InfoRegisterMapper, InfoRegister> implements IInfoRegisterService {

    private final InfoRegisterWrapper infoRegisterWrapper;

    @Override
    @Transactional(rollbackFor=RuntimeException.class)
    public boolean save(InfoRegisterVO infoRegisterVO) {
        InfoRegister infoRegister = infoRegisterWrapper.voToEntity(infoRegisterVO);
        return saveOrUpdate(infoRegister);
    }
    
    /**
     * 提交企业信息
     *
     * @param infoRegisterVO 企业信息登记表VO
     * @return 操作结果
     */
    @Transactional(rollbackFor=RuntimeException.class)
    public ResponseEntity<?> submit(InfoRegisterVO infoRegisterVO) {
        boolean result = this.save(infoRegisterVO);
        if(!result){
            return ResponseEntity.badRequest().build();
        }
        InfoRegister infoRegister = infoRegisterWrapper.voToEntity(infoRegisterVO);
        return ResponseEntity.ok(infoRegister);
    }



}
